from django.db import models

class Base(models.Model):
    id = models.AutoField(primary_key=True)
    
    class Meta:
        abstract = True
        
        
class User(Base):
    # 用户名,最大长度200
    username = models.CharField(max_length=200)
    # 密码,最大长度200
    password = models.CharField(max_length=200)
    # 用户头像
    img = models.CharField(max_length=200)
    # 根据分类数字来区别用户权限
    # 0 普通用户
    # 1 管理员
    # 2 商家
    type = models.IntegerField()
    # 自定义表明
    class Meta:
        db_table = 'user'
        
# 商品表
class Goods(Base):
    # 商品名称给
    name = models.CharField(max_length=200)
    # 商品描述
    desc = models.CharField(max_length=500)
    # 商品图片
    img = models.CharField(max_length=200)
    # 演示视频
    video = models.CharField(max_length=200)
    # 关注数量
    flow = models.IntegerField(default=0,null=True)
    # 价格
    price = models.IntegerField()
    
    class Meta:
        db_table = 'goods'
    
# 分类表
class Category(Base):
    cname = models.CharField(max_length=200)
    
    class Meta:
        db_table = 'category'
        
        
# 幻灯片      
class Pics(Base):
    # 名称
    title = models.CharField(max_length=200)
    # 链接
    link = models.CharField(max_length=200)
    # 图片
    image = models.CharField(max_length=200)
    
    
    class Meta:
        db_table = 'pics'
        
        
class Comments(Base):
    # 内容
    comment = models.CharField(max_length=500)
    # 用户名
    uid = models.IntegerField()
    # 商品名
    gid = models.IntegerField()
    
    
    class Meta:
        db_table = 'comments'
        
        
# #关注表
class UserFlow(Base):

	#谁关注的
	uid = models.IntegerField()
	#关注的那个商品
	gid = models.IntegerField()
 
    # class Meta:
    #     unique_together = (
    #         ('uid', 'gid'),
    #     )
    #     db_table = 'userflow'